package chapter08.abstractQueuedSynchronizer;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

@Slf4j
public class MyLockTest {
    public static void main(String[] args) {

        MyLock myLock = new MyLock();
        new Thread(()->{
            myLock.lock();
            try {
                Thread.sleep(5000);
                log.debug("t1开始了");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }finally {
                myLock.unlock();
            }
        },"t1").start();
        new Thread(()->{
            try {
                myLock.lock();
                log.debug("t2开始了");
            }finally {
                myLock.unlock();
            }
        },"t2").start();
    }
}
